'''
Created on Jul 29, 2010

@author: swaron
'''

class CDTProjectFile(object):
    '''
    classdocs
    '''
    buildinDefines = ['__pragma(x)']
    defines = [];
    includes = [];
    includeLibPaths = [];
    includeLibs = [];
    projectName = 'ToBeReplaced';
#    <listOptionValue builtIn="false" value="&quot;D:\WTL80\include&quot;"/>
#                                    <listOptionValue builtIn="false" value="UNICODE=1"/>
#                                    <listOptionValue builtIn="false" value="_UNICODE"/>
    def __init__(self):
        '''
        Constructor
        '''
        pass
    def generateMakefile(self):
        return self.__makefile;
    def generateProject(self):
        content = self.__projectTemplate.replace('$[ProjectName]', self.projectName);
        return content;
    def generateCProject(self):
        incStr = '';
        for inc in self.includes:
            incStr += '\t'*9 + '<listOptionValue builtIn="false" value="&quot;'+inc+'&quot;"/>\n';
        
        defStr = '';
        for define in self.defines + self.buildinDefines:
            defStr += '\t'*9 + '<listOptionValue builtIn="false" value="'+define+'"/>\n';
            
        includeLibPathsStr = '';
        for path in self.includeLibPaths:
            includeLibPathsStr += '\t'*9 + '<listOptionValue builtIn="false" value="&quot;'+path+'&quot;"/>\n';
        
        includeLibsStr = '';
        for lib in self.includeLibs:
            includeLibsStr += '\t'*9 + '<listOptionValue builtIn="false" value="'+lib+'"/>\n';
        
        content = self.__cprojectTemplate.replace('$[ProjectName]', self.projectName);
        content = content.replace('$[IncludePaths]', incStr);
        content = content.replace('$[MacroList]', defStr);
        content = content.replace('$[IncludeLibPaths]', includeLibPathsStr);
        content = content.replace('$[IncludeLibs]', includeLibsStr);
        return content;
    
    __makefile = """Configuration = Debug
build :
    BuildVCProject.py build $(Configuration)
rebuild : 
    BuildVCProject.py rebuild $(Configuration)
clean :
    BuildVCProject.py clean $(Configuration)
all : build
"""
    __projectTemplate = """<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>$[ProjectName]</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
            <triggers>clean,full,incremental,</triggers>
            <arguments>
                <dictionary>
                    <key>?name?</key>
                    <value></value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.append_environment</key>
                    <value>true</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
                    <value>all</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.buildArguments</key>
                    <value></value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.buildCommand</key>
                    <value>nmake</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
                    <value>clean</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.contents</key>
                    <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
                    <value>false</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
                    <value>true</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.enableFullBuild</key>
                    <value>true</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
                    <value>all</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.stopOnError</key>
                    <value>true</value>
                </dictionary>
                <dictionary>
                    <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
                    <value>false</value>
                </dictionary>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
            <triggers>full,incremental,</triggers>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.cdt.core.cnature</nature>
        <nature>org.eclipse.cdt.core.ccnature</nature>
        <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
        <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
    </natures>
</projectDescription>
"""
    __cprojectTemplate = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?>

<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
    <storageModule moduleId="org.eclipse.cdt.core.settings">
        <cconfiguration id="0.1859202944">
            <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1859202944" moduleId="org.eclipse.cdt.core.settings" name="Default">
                <externalSettings/>
                <extensions>
                    <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
                    <extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
                </extensions>
            </storageModule>
            <storageModule moduleId="cdtBuildSystem" version="4.0.0">
                <configuration artifactName="${ProjName}" buildProperties="" description="" errorParsers="org.eclipse.cdt.core.VCErrorParser" id="0.1859202944" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
                    <folderInfo id="0.1859202944." name="/" resourcePath="">
                        <toolChain errorParsers="" id="org.eclipse.cdt.build.core.prefbase.toolchain.1440779478" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
                            <targetPlatform binaryParser="org.eclipse.cdt.core.PE" id="org.eclipse.cdt.build.core.prefbase.toolchain.1440779478.436522476" name=""/>
                            <builder autoBuildTarget="all" cleanBuildTarget="clean" command="nmake" enableAutoBuild="false" enableCleanBuild="true" enabledIncrementalBuild="true" errorParsers="" id="org.eclipse.cdt.build.core.settings.default.builder.1291567494" incrementalBuildTarget="all" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelizationNumber="1" superClass="org.eclipse.cdt.build.core.settings.default.builder"/>
                            <tool errorParsers="org.eclipse.cdt.core.VCErrorParser" id="org.eclipse.cdt.build.core.settings.holder.libs.131347551" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs">
                                <option id="org.eclipse.cdt.build.core.settings.holder.libpaths.450402167" superClass="org.eclipse.cdt.build.core.settings.holder.libpaths" valueType="libPaths">
$[IncludeLibPaths]
                                </option>
                                <option id="org.eclipse.cdt.build.core.settings.holder.libfiles.726153942" superClass="org.eclipse.cdt.build.core.settings.holder.libfiles" valueType="libFiles">
$[IncludeLibs]
                                </option>
                            </tool>
                            <tool errorParsers="org.eclipse.cdt.core.VCErrorParser" id="org.eclipse.cdt.build.core.settings.holder.1223867796" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
                                <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.969193261" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
                            </tool>
                            <tool errorParsers="org.eclipse.cdt.core.VCErrorParser" id="org.eclipse.cdt.build.core.settings.holder.2075557112" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
                                <option id="org.eclipse.cdt.build.core.settings.holder.incpaths.907080022" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
$[IncludePaths]                                
                                </option>
                                <option id="org.eclipse.cdt.build.core.settings.holder.symbols.848142434" superClass="org.eclipse.cdt.build.core.settings.holder.symbols" valueType="definedSymbols">
$[MacroList]
                                </option>
                                <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.994559482" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
                            </tool>
                            <tool errorParsers="org.eclipse.cdt.core.VCErrorParser" id="org.eclipse.cdt.build.core.settings.holder.1176331271" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
                                <inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1103370630" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
                            </tool>
                        </toolChain>
                    </folderInfo>
                </configuration>
            </storageModule>
            <storageModule moduleId="scannerConfiguration">
                <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
                <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="makefileGenerator">
                        <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
                    <buildOutputProvider>
                        <openAction enabled="true" filePath=""/>
                        <parser enabled="true"/>
                    </buildOutputProvider>
                    <scannerInfoProvider id="specsFile">
                        <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
                        <parser enabled="true"/>
                    </scannerInfoProvider>
                </profile>
                <scannerConfigBuildInfo instanceId="0.1859202944">
                    <autodiscovery enabled="false" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP"/>
                    <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="makefileGenerator">
                            <runAction arguments="-E -P -v -dD" command="" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="" command="" useDefault="true"/>
                            <parser enabled="false"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/${specs_file}&quot;'" command="sh" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-c 'g++ -E -P -v -dD &quot;${plugin_state_location}/specs.cpp&quot;'" command="sh" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                    <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
                        <buildOutputProvider>
                            <openAction enabled="true" filePath=""/>
                            <parser enabled="true"/>
                        </buildOutputProvider>
                        <scannerInfoProvider id="specsFile">
                            <runAction arguments="-c 'gcc -E -P -v -dD &quot;${plugin_state_location}/specs.c&quot;'" command="sh" useDefault="true"/>
                            <parser enabled="true"/>
                        </scannerInfoProvider>
                    </profile>
                </scannerConfigBuildInfo>
            </storageModule>
            <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
            <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
            <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
        </cconfiguration>
    </storageModule>
    <storageModule moduleId="cdtBuildSystem" version="4.0.0">
        <project id="$[ProjectName].null.253039187" name="$[ProjectName]"/>
    </storageModule>
</cproject>
"""
    
